/**
 * 
 */
package com.swim.recruitment.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.sys.utils.UserUtils;
import com.swim.recruitment.entity.Position;
import com.swim.webuser.service.WebUserService;
import com.swim.natatoriuminfo.service.NatatoriumInfoService;
import com.swim.recruitment.dao.PositionDao;

/**
 * 岗位Service
 * @author ljw
 * @version 2023-05-30
 */
@Service
@Transactional(readOnly=true)
public class PositionService extends CrudService<PositionDao, Position> {
	
    @Autowired
    private WebUserService webUserService;
    
    @Autowired
    private NatatoriumInfoService natatoriumInfoService;
    
	/**
	 * 获取单条数据
	 * @param position
	 * @return
	 */
	@Override
	public Position get(Position position) {
		return super.get(position);
	}
	
	/**
	 * 查询分页数据
	 * @param page 分页对象
	 * @param position
	 * @return
	 */
	@Override
	public Page<Position> findPage(Page<Position> page, Position position) {
		return super.findPage(page, position);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param position
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(Position position) {
        String natatoriumInfoId = webUserService.getNatatoriumInfoIdByUserCode(UserUtils.getUser().getUserCode());
        position.setNatatoriumInfoId(natatoriumInfoId);
        position.setNatatoriumName(natatoriumInfoService.get(natatoriumInfoId).getName());
		super.save(position);
	}
	
	/**
	 * 更新状态
	 * @param position
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(Position position) {
		super.updateStatus(position);
	}
	
	/**
	 * 删除数据
	 * @param position
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(Position position) {
		super.delete(position);
	}
	
}